package com.chatdating.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.chatdating.entity.OrderInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDateTime;

@Mapper
public interface OrderInfoMapper extends BaseMapper<OrderInfo> {
    /**
     * 更新订单支付状态
     */
    @Update("UPDATE order_info SET " +
            "status = #{status}, " +
            "payment_time = #{paymentTime}, " +
            "alipay_trade_no = #{alipayTradeNo}, " +
            "update_time = NOW() " +
            "WHERE order_no = #{orderNo} AND status = 0")
    int updateOrderStatus(
            @Param("orderNo") String orderNo,
            @Param("status") Integer status,
            @Param("paymentTime") LocalDateTime paymentTime,
            @Param("alipayTradeNo") String alipayTradeNo
    );
}
